<template>
    <div class="app-container">
        <div class="filter-container">
            <el-button
                class="filter-item"
                style="margin-left: 10px"
                type="primary"
                icon="el-icon-edit"
                @click="saveOrUpdate()"
            >
                保存
            </el-button>
        </div>
        <el-table
            v-loading="listLoading"
            :data="scheduleList"
            style="width: 100%; margin-top: 10px"
            border
            @selection-change="selectrule"
        >
            <el-table-column
                type="selection"
                width="55"
                @selection-change="selectrule"
            ></el-table-column>
            <el-table-column
                prop="code"
                align="center"
                sortable
                label="医生名称"
            >
                <template slot-scope="scope">
                    {{ scope.row.username }}
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期一上午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[0]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期一下午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[1]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期二上午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[2]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期二下午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[3]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期三上午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[4]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期三下午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[5]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期四上午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[6]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期四下午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[7]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期五上午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[8]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期五下午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[9]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期六上午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[10]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期六下午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[11]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期日上午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[12]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column align="center" label="星期日下午" width="70px">
                <template slot-scope="scope">
                    <el-checkbox
                        v-model="scope.row.skdList[13]"
                    ></el-checkbox>
                </template>
            </el-table-column>
            <el-table-column label="排班限额" align="center" width="100px">
                <template slot-scope="scope">
                    <el-input
                        v-model="scope.row.skLimit"
                        placeholder=""
                    ></el-input>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>


<script>
import { ruleItemList, saveOrUpdateItem } from "@/api/sms/ruleItem";

export default {
    filters: {
        statusFilter(status) {
            const statusMap = {
                published: "success",
                draft: "gray",
                deleted: "danger",
            };
            return statusMap[status];
        },
    },
    data() {
        return {
            listLoading: true,
            scheduleList: [],
        };
    },
    created() {
        this.listLoading = true;
        ruleItemList({ deptId: this.$route.query.deptId, ruleId: this.$route.query.ruleId }).then((res) => {
            if (res.code == 200) {
                this.scheduleList = res.data;
                this.listLoading = false;
            }
        });
    },
    methods: {
        selectrule() {},

        saveOrUpdate() {
            saveOrUpdateItem({ruleId:this.$route.query.ruleId, itemList: this.scheduleList}).then((res) => {
                if(res.code == 200) {
                    // console.log("haha")
                    this.$router.push("/skd/rule")
                }
            })
        }
    },
};
</script>

<style lang="scss" scoped>
.app-container {
    .roles-table {
        margin-top: 30px;
    }
    .permission-tree {
        margin-bottom: 30px;
    }
}
</style>
